<?php /*a:1:{s:63:"D:\work\web\write_play_1\application\index\view\user\login.html";i:1554884919;}*/ ?>

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script src="/static/js/jquery-3.3.1.min.js"></script>
	<script src="/static/js/jsencrypt.min.js"></script>
	<script src="/static/js/gt.js"></script>
	<script src="/static/layui-v2.4.5/layui//layui.js"></script>
	<link rel="stylesheet" href="/static/layui-v2.4.5/layui//css/layui.css" type="text/css" />
</head>
<style type="text/css">
		.disp_none{
			font-size:15px;
			color:red;
			display: none;
			height: 20px;
		}
		
		
		#login_form {
            width: 300px;
            margin: 10% auto;
        }
        .show {
            display: block;
        }
        .hide {
            display: none;
        }
        #notice {
            color: red;
        }
        #embed-captcha{
        	margin-top: 30px;
        }
	</style>
<body>

<form id="login_form" class="layui-form" >
	<image src="/static/image/logo.jpg" style="width:300px;height: 150px;"/>
<div style="height: 20px;margin:10px;">
<label id="login_error" class="disp_none"></label>
</div>

<div class="layui-form-item">
<input type="text" name="account" class="layui-input" placeholder="手机号">
</div>
<div class="layui-form-item">
<input type="password" name="password" class="layui-input" placeholder="密码">
</div>
<div id="embed-captcha" class="layui-form-item"></div>
<div id="wait" class="layui-form-item" style="text-align: center;color:gray;">正在加载验证码......</div>
    
<div class="layui-form-item"><div class="layui-input-inline" style="width: 300px;margin:0px;">
	<span style="width: 100px;float: left;">
<input  type="checkbox" name='remember_me'title="自动登录" lay-skin="primary">
</span>

<div class="layui-form-mid" style="float: right;">
<a href="forget_pwd" style="color:gray;">忘记密码</a>
</div>
</div>
</div>
<div class="layui-form-item">
<input type="button" id="login" style="width: 300px;" class="layui-btn layui-btn-normal" value="登陆">
</div>

<div class="layui-form-item">
<input type="button" onclick="window.location.href='register'" style="width: 300px;" class="layui-btn layui-btn-primary" value="滚去注册">
</div>
</form>

</body>

 

<script type="text/javascript">
	layui.use('form', function(){
  		var form = layui.form;
	});
	$(document).keydown(function(event){
　　　		　if(event.keyCode == '13' && $(':focus').prop('id') != 'login')
			$('#login').click();
　　   });
	

		$('#login').click(function(){
			var rsa = new JSEncrypt();
			rsa.setPublicKey("-----BEGIN PUBLIC KEY-----\
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3WvMS6rbQLOxcwwGOYSxoRIv1\
XRlUs+CW21Q/+SfX3xnMmh72jObiUUV243Ilrnxp91+nmf4o7OZbp/EvjlkJRNvz\
+9HxZsr1ZVb3TafSAUvUanrsLkHhfAJHQQexX1Tpd4yUWLWxPkvVR975hNy7mOSF\
SBNNqbSEiFhTg2SyuwIDAQAB\
-----END PUBLIC KEY-----\
",'10001');
			var pwd = rsa.encrypt($('input[name="password"]').val());
			var mobile = $('input[name="account"]').val();
			var remember = $('input[name="remember_me"]').prop('checked') ? 1 : 0;
			var geetest_challenge = $('input[name="geetest_challenge"]').val();
			var geetest_validate = $('input[name="geetest_validate"]').val();
			var geetest_seccode = $('input[name="geetest_seccode"]').val();
			
		
			$.ajax({
				type:'post',
				url:'login',
				data:
				{'mobile':mobile,'password':pwd,'remember':remember,'geetest_seccode':geetest_seccode,'geetest_validate':geetest_validate,'geetest_challenge':geetest_challenge},
				dataType:'json',
				success:function(res){
					
					if(res !== true){
						$('#login_error').text(res).css('display','block');
						$('#wait').css('display','block');
						setCaptchaObj();
					}
					else{
						window.location.href = '/index';
					}
				},
				error:function(){
					$('#wait').css('display','block');
					setCaptchaObj();
				}
		})
		
	})
	

function setCaptchaObj(){
	$('#embed-captcha').empty();
	var handler = function(captchaObj){

    	captchaObj.appendTo("#embed-captcha");
   	
		   captchaObj.onReady(function () {
		       $('#wait').css('display','none');
		    });
	}
	$.ajax({
	   url: "<?php echo geetest_url(); ?>?t=" + (new Date()).getTime(),
	   type: "get",
	   dataType: "json",
	   success: function (data) {
	   initGeetest({
	        gt: data.gt,
	        challenge: data.challenge,
	        product: "float", 
	        offline: !data.success 
	      }, handler);
	   },
	   error: function(){
	   	console.log('error');
	   }
	});
}
setCaptchaObj();
</script>
</html>

